<template>
  <div class="mainBox">
    <h1
      class="title"
    ><i class="el-icon-office-building" /> <i>{{ title }}</i></h1>
    <el-table :data="table" border style="width: 100%" @row-click="rowClick">
      <el-table-column :prop="change" :label="change==='image'?'图片':'标题'">
        <template #default="{row}">
          <img v-if="change==='image'" :src="row.image || 'https://hmhr-1308572366.cos.ap-nanjing.myqcloud.com/flog.png'" alt="" style="height:240px">
          <div v-else>{{ row.title }}</div>
        </template>
      </el-table-column>
      <el-table-column :prop="type" :label="type==='name'?'名称':type==='address'? '地址':'内容'" width="598px">
        <template #default="{row}">
          <div v-if="row.address">{{ row.address }}</div>
          <div v-else v-html="row.content">{{ row.content }}</div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ''
    },
    table: {
      type: Array,
      required: true
    },
    type: {
      type: String,
      default: 'name'
    },
    change: {
      type: String,
      default: 'image'
    }
  },
  data() {
    return {
      image: ''
    }
  },
  methods: {
    rowClick(row) {
      console.log(row)
      this.$emit('btn', row.id)
    }
  }
}
</script>
<style lang="less" scoped>
.mainBox{
  width: 900px;
  // background-color: pink;
  margin: 0 auto;
  img{
    width: 100%;
  }
  .title{
    color:orange ;
  }
  ::v-deep .el-table td.el-table__cell div{
    display: -webkit-box !important;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
  }
}
</style>
